package behaviours.tourguide;

import agents.TourGuideAgent;
import jade.core.behaviours.CyclicBehaviour;
import jade.lang.acl.ACLMessage;
import jade.lang.acl.MessageTemplate;

public class ListenForCustomers extends CyclicBehaviour {
	TourGuideAgent tourGuide;
	public ListenForCustomers(TourGuideAgent agent){
		super(agent);
		this.tourGuide = agent;
	}
	@Override
	public void action() {
		ACLMessage msg = tourGuide.receive(MessageTemplate.MatchPerformative(ACLMessage.REQUEST));
		if (msg != null){
			System.out.println("adding negotiateToursalebehaviour");
			tourGuide.addBehaviour(new NegotiateTourSaleBehaviour(msg.getSender(), tourGuide));
		} else {
			block();
		}
	}
}
